package com.asiainfo.dacp.datastash.domain.unit.models;

import com.asiainfo.dacp.domain.AggregateRoot;
import com.asiainfo.dacp.metamodel.domain.team.model.MetaTeamMember;
import com.asiainfo.dacp.util.DateHelper;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
public class DataStashUnit implements AggregateRoot {

    private String id;

    private String unitCode;

    private String label;

    private String descr;

    private String unitType;

    private String workgroup;

    private String batchType;

    private int batchStep;

    private int batchOffset;

    private String batchNo;

    private int unitPriority;

    private String runConstraint;

    private MetaTeamMember teamMember;

    private String createUser;

    @JsonIgnore
    private Date createDt;

    @JsonIgnore
    private Date lastupd;

    private String unitExtCfg;

    private String graph;

    private String state;

    private String lastupDate;

    private String createDate;

    private Map<String,DataStashUnitStep> stepIndex;

    private List<DataStashUnitStep> rootSteps;

    private List<DataStashUnitStep> unitSteps;

    public String getLastupDate(){
        return DateHelper.formatDateTime(lastupd);
    }

    public String getCreateDate(){
        return DateHelper.formatDateTime(createDt);
    }

    public void setLastupDate(String lastupDate){
        lastupd = DateHelper.parseDateTime(lastupDate);
    }

    public void setCreateDate(String createDate){
        createDt = DateHelper.parseDateTime(createDate);
    }
}
